//
//  WYCBillFrameModel.m
//  信用卡管理
//
//  Created by 中企互联 on 2017/11/8.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCBillFrameModel.h"
#define fourFont [UIFont systemFontOfSize:40 * px]

@implementation WYCBillFrameModel
- (void)setBillmodel:(WYCBillModel *)Billmodel{
    _Billmodel = Billmodel;
    
    //cell的高度
    CGFloat cellW = ScreenWidth;
    if ([Billmodel.userId isEqualToString:@"-2"]) {
        //topView XYW
        CGFloat topViewX = 20 * px;
        CGFloat topViewY = 10 * px;
        CGFloat topViewW = cellW - 40 * px;
        
        CGFloat bigtopViewX = 20 * px;
        CGFloat bigtopViewY = 0 * px;
        CGFloat bigtopViewW = topViewW - 40 * px;
        
        //图片
        _imageViewF = CGRectMake(60 * px, 80 * px, 80 * px, 80 * px);
        
        //银行昵称
        
        CGFloat addcardY = 40 * px;
        NSString * addcardStr = [NSString stringWithFormat:@"%@",Billmodel.addcard];
        CGSize bankNameSize = [addcardStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        CGFloat addcardX = cellW  / 3;
        _addcardF =  (CGRect){{addcardX, addcardY}, bankNameSize};
        
        CGFloat bigtopViewH = CGRectGetMaxY(_addcardF) + 60*px;
        
        _bigtopViewF = CGRectMake(bigtopViewX, bigtopViewY, bigtopViewW, bigtopViewH);
        
        
        CGFloat topViewH = CGRectGetMaxY(_bigtopViewF) + 100 * px;
        
        _topViewF = CGRectMake(topViewX, topViewY, topViewW, topViewH);
        
        
        _cellHeight = topViewH;
    }
    else if ([Billmodel.userId isEqualToString:@"-1"]) {
        
        //topView XYW
        CGFloat topViewX = 20 * px;
        CGFloat topViewY = 10 * px;
        CGFloat topViewW = cellW - 40 * px;
        
        CGFloat bigtopViewX = 0;
        CGFloat bigtopViewY = 0 * px;
        CGFloat bigtopViewW = topViewW;
        
        
        //图片
        _imageViewF = CGRectMake(60 * px, 60 * px, 80 * px, 80 * px);
        
        //银行昵称
        CGFloat lineX = 0;
        CGFloat lineY = CGRectGetMaxY(_imageViewF) + 60 * px;
        CGFloat lineW = bigtopViewW;
        CGFloat lineH = 0.5;
        _lineF = CGRectMake(lineX, lineY, lineW, lineH);
        
        
        //银行昵称
        CGFloat bankNameX = CGRectGetMaxX(_imageViewF) + 40 * px;
        CGFloat bankNameY = 60 * px;
        NSString * bankNameStr = [NSString stringWithFormat:@"%@(%@)",Billmodel.bankName,Billmodel.lastNumber];
        CGSize bankNameSize = [bankNameStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        _bankNameF =  (CGRect){{bankNameX, bankNameY}, bankNameSize};
        
        
        //姓名
        CGFloat NameX = bigtopViewW - 225 * px;
        CGFloat NameY = bankNameY;
        NSString * NameStr = [NSString stringWithFormat:@"%@",Billmodel.name];
        CGSize NameSize = [NameStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        _nameF = (CGRect){{NameX,NameY},NameSize};
        
        
        
        
        
        
        
        
        //天数————————账单日
        CGFloat outbBllDayX = 60 * px;
        CGFloat outbBllDayY = CGRectGetMaxY(_lineF) + 60 * px;
        NSString * outbBllDayStr = [NSString stringWithFormat:@"0天后出账单"];
        CGSize outbBllDaySize = [outbBllDayStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:60 * px]}];
        _outbBllDayF = (CGRect){{outbBllDayX,outbBllDayY},outbBllDaySize};
        
        
        _approveF = CGRectMake(topViewW - 350 * px, outbBllDayY, 250 * px, 48 * px);
        
        
        
        
        //几号————————账单日
        CGFloat billDateX = outbBllDayX;
        CGFloat billDateY = CGRectGetMaxY(_outbBllDayF) + 60 * px;
        NSString * billDateStr = [NSString stringWithFormat:@"账单日：%@",Billmodel.billDate];
        CGSize billDateSize = [billDateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        _billDateF = (CGRect){{billDateX,billDateY},billDateSize};
        
        
        //几号————————还款日
        CGFloat dueDateY = billDateY;
        NSString * dueDateStr = [NSString stringWithFormat:@"还款日：%@",Billmodel.dueDate];
        CGSize dueDateSize = [dueDateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        CGFloat dueDateX = topViewW - 120 * px - dueDateSize.width;
        _dueDateF = (CGRect){{dueDateX,dueDateY},dueDateSize};
        
        
        
        
        
        CGFloat bigtopViewH = CGRectGetMaxY(_dueDateF) + 60 * px;
        
        _bigtopViewF = CGRectMake(bigtopViewX, bigtopViewY, bigtopViewW, bigtopViewH);
        
        
        CGFloat topViewH = CGRectGetMaxY(_bigtopViewF);
        
        
        
        _topViewF = CGRectMake(topViewX, topViewY, topViewW, topViewH);
        
        
        _cellHeight = topViewH;
    }else{
        //topView XYW
        CGFloat topViewX = 20 * px;
        CGFloat topViewY = 0;
        CGFloat topViewW = cellW;
        
        CGFloat bigtopViewX = 0 * px;
        CGFloat bigtopViewY = 0 * px;
        CGFloat bigtopViewW = cellW - 40 * px;
        
        
        //图片
        _imageViewF = CGRectMake(60 * px, 60 * px, 80 * px, 80 * px);
        
        //银行昵称
        CGFloat lineX = 0;
        CGFloat lineY = CGRectGetMaxY(_imageViewF) + 60 * px;
        CGFloat lineW = bigtopViewW;
        CGFloat lineH = 0.5;
        _lineF = CGRectMake(lineX, lineY, lineW, lineH);
        
        
        //银行昵称
        CGFloat bankNameX = CGRectGetMaxX(_imageViewF) + 40 * px;
        CGFloat bankNameY = 60 * px;
        NSString * bankNameStr = [NSString stringWithFormat:@"%@(%@)",Billmodel.bankName,Billmodel.lastNumber];
        CGSize bankNameSize = [bankNameStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        _bankNameF =  (CGRect){{bankNameX, bankNameY}, bankNameSize};
        
        
        //姓名
        CGFloat NameX = bigtopViewW - 225 * px;
        CGFloat NameY = bankNameY;
        NSString * NameStr = [NSString stringWithFormat:@"%@",Billmodel.name];
        CGSize NameSize = [NameStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        _nameF = (CGRect){{NameX,NameY},NameSize};
        
        
        
        CGFloat billAmountX = 60 * px;
        CGFloat billAmountY = CGRectGetMaxY(_lineF) + 60 * px;
        NSString * billAmountStr = [NSString stringWithFormat:@"%.2f",[Billmodel.billAmount doubleValue]];
        CGSize billAmountSize = [billAmountStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:70 * px]}];
        WYCLog(@"==============%@",billAmountStr);
        _billAmountF = (CGRect){{billAmountX,billAmountY},billAmountSize};
        
        
        
        
        //天数————————账单日
        CGFloat outbBllDayX = CGRectGetMaxX(_billAmountF) + 40 * px;
        CGFloat outbBllDayY = billAmountY;
        NSString * outbBllDayStr = [NSString stringWithFormat:@"%@ 天后出账单",Billmodel.outbBllDay];
        CGSize outbBllDaySize = [outbBllDayStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:60 * px]}];
        _outbBllDayF = (CGRect){{outbBllDayX,outbBllDayY},outbBllDaySize};
        
        if ([Billmodel.state isEqualToString:@"0"]) {
            NSString * stateStr = [NSString stringWithFormat:@""];
            CGSize stateSize = [stateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
            _approveF = (CGRect){{topViewW - 350 * px, outbBllDayY},stateSize};
        }else if ([Billmodel.state isEqualToString:@"1"]){
            
            self.nameStr = [NSString stringWithFormat:@"待还款"];
            CGSize stateSize = [self.nameStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
            _approveF = (CGRect){{topViewW - 350 * px, outbBllDayY},stateSize};
        }else if ([Billmodel.state isEqualToString:@"2"]){
            NSString * stateStr = [NSString stringWithFormat:@"已还清"];
            CGSize stateSize = [stateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
            _approveF = (CGRect){{topViewW - 350 * px, outbBllDayY},stateSize};
            
        }else if ([Billmodel.state isEqualToString:@"3"]){
            NSString * stateStr = [NSString stringWithFormat:@"智能还款中"];
            CGSize stateSize = [stateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
            _approveF = (CGRect){{topViewW - 350 * px, outbBllDayY},stateSize};
            
        }else{
            NSString * stateStr = [NSString stringWithFormat:@"智能还款中止"];
            CGSize stateSize = [stateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
            _approveF = (CGRect){{topViewW - 350 * px, outbBllDayY},stateSize};
            
        }
        
        
        
        
        _approveF = CGRectMake(topViewW - 350 * px, outbBllDayY, 250 * px, 48 * px);
        
        
        
        
        //几号————————账单日
        CGFloat billDateX = billAmountX;
        CGFloat billDateY = CGRectGetMaxY(_outbBllDayF) + 60 * px;
        NSString * billDateStr = [NSString stringWithFormat:@"账单日：%@",Billmodel.billDate];
        CGSize billDateSize = [billDateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        _billDateF = (CGRect){{billDateX,billDateY},billDateSize};
        
        
        //几号————————还款日
        CGFloat dueDateY = billDateY;
        NSString * dueDateStr = [NSString stringWithFormat:@"还款日：%@",Billmodel.dueDate];
        CGSize dueDateSize = [dueDateStr sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:50 * px]}];
        CGFloat dueDateX = topViewW - 120 * px - dueDateSize.width;
        _dueDateF = (CGRect){{dueDateX,dueDateY},dueDateSize};
        
        
        
        
        
        CGFloat bigtopViewH = CGRectGetMaxY(_dueDateF) + 60 * px;
        
        _bigtopViewF = CGRectMake(bigtopViewX, bigtopViewY, bigtopViewW, bigtopViewH);
        
        //    WYCLog(@"")
        CGFloat topViewH = CGRectGetMaxY(_bigtopViewF);
        
        
        
        _topViewF = CGRectMake(topViewX, topViewY, topViewW, topViewH);
        
        
        _cellHeight = topViewH;
        
    }
    
}
@end

